package javabase.thinkinjava.nio;

import java.nio.ByteBuffer;

import static javabase.thinkinjava.nio.GetChannel.BSIZE;

/**
 * @author fance
 * @date 18-4-30 上午8:58
 */
public class GetData {
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(BSIZE);

        int i = 0;
        while (i++ < buffer.limit()) {
            if (buffer.get() != 0) {
                System.out.print("nonzero");
            }
        }
        System.out.println("i = " + i);
        buffer.rewind();
        buffer.asCharBuffer().put("fance");
        char c;
        while ((c = buffer.getChar()) != 0) {
            System.out.print(c + " ");
        }
        System.out.println();

        buffer.rewind();
        buffer.asIntBuffer().put(123);
        System.out.println(buffer.getInt());
        // ... double ...
    }
}
